﻿#!/usr/bin/perl -w
use Net::FTP;
  
my $username = 'omc';  
my $password = 'omc';  
my $remoteDir = "/tmp/xqd/";  
my $localDir = "C:/Users/xuuuvqin/Desktop/GenOMesFile/Output/OMeSFiles_20130426/";

opendir (DIR, $localDir) or die "can't open it:$!"; 
my @filelist = readdir DIR;
closedir(DIR); 
  
$ftp = Net::FTP->new("10.91.17.170",Timeout => 30) or die "Can't connect: $@\n";  
$ftp->login($username, $password) or die "Could not log in.\n";  

if ($ftp->cwd($remoteDir)) {
		
	print "I'm in the directory ", $ftp->pwd(), "\n"; 
	foreach $file (@filelist) {
		next unless($file =~ /.xml/);
		$file = $localDir.$file;
		print "--file:$file\n";
		my $result = $ftp->put($file);
		#if(defined $result){
		# 　　unlink($file); # 将上传成功的文件在本地删除
		# 　　push @successlist, $file;
		# }
	}
}

# $ftp->get($remotefile, $localfile)   or die "Can't fetch $remotefile : $!\n";  
# $ftp->put($filename, $remotefilename) or die "Couldn't put $filename\n";  
 